package com.yyjj.hangqing.adapter;

import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yyjj.hangqing.R;
import com.yyjj.hangqing.entity.HqRiseEntity;

import java.math.BigDecimal;

import tech.com.commoncore.manager.GlideManager;

public class HqRiseAdapter extends BaseQuickAdapter<HqRiseEntity, BaseViewHolder> {
    public HqRiseAdapter() {
        super(R.layout.hq_ride_item);
    }

    @Override
    protected void convert(BaseViewHolder helper, HqRiseEntity item) {
        helper.setText(R.id.name_tv, item.getCoin_full_name());
        helper.setText(R.id.open_tv, "￥" + new BigDecimal(item.getOpen()).setScale(2, BigDecimal.ROUND_HALF_UP));
        ImageView imageView = (ImageView) helper.getView(R.id.img_up_down);
        helper.setText(R.id.zdf_tv, item.getCoin_price_limit() + "%");
        if (item.getCoin_price_limit().contains("-")) {
            GlideManager.loadImg(mContext.getResources().getDrawable(R.mipmap.down), imageView, mContext.getResources().getDrawable(R.mipmap.down));
            helper.setBackgroundRes(R.id.ll_item, R.drawable.hq_bg_content_green_round_5);
            ((TextView) helper.getView(R.id.open_tv)).setTextColor(mContext.getResources().getColor(R.color.green));
            ((TextView) helper.getView(R.id.zdf_tv)).setTextColor(mContext.getResources().getColor(R.color.green));
        } else {
            GlideManager.loadImg(mContext.getResources().getDrawable(R.mipmap.up), imageView, mContext.getResources().getDrawable(R.mipmap.up));
            helper.setBackgroundRes(R.id.ll_item, R.drawable.hq_bg_content_red_round_5);
            ((TextView) helper.getView(R.id.open_tv)).setTextColor(mContext.getResources().getColor(R.color.red));
            ((TextView) helper.getView(R.id.zdf_tv)).setTextColor(mContext.getResources().getColor(R.color.red));
        }
    }
}
